using System;

namespace Grebok.Persistence.AdoNet
{
    using Grebok.Domain;

	/// <summary>
    /// A Employee proxy adding lazy loading capabilities for "Notes" and "Photo" properties
	/// </summary>
	internal sealed class EmployeeProxy : Employee
	{
        private bool notesLoaded = false;
        private bool photoLoaded = false;

		public override string Notes
		{
			get
			{
                string notes;
                if (!notesLoaded)
                {
                    EmployeeDataMapper dataProvider = new EmployeeDataMapper();
                    notes = dataProvider.GetNotesById(this.Id);
                    notesLoaded = true;
                    base.Notes = notes;
                }
                else
                {
                    notes = base.Notes;
                }
                return notes;
			}
			set
			{
				base.Notes = value;
                notesLoaded = true;
			}
		}

		public override System.Drawing.Bitmap Photo
		{
			get
			{
                System.Drawing.Bitmap photo;
                if (!photoLoaded)
                {
                    EmployeeDataMapper dataProvider = new EmployeeDataMapper();
                    photo = dataProvider.GetPhotoById(this.Id);
                }
                else
                {
                    photo = base.Photo;
                }
                return photo;
			}
			set
			{
				base.Photo = value;
                photoLoaded = true;
			}
		}

	}
}
